-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add initial pinctrl support for NXP kinetis #39743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add initial version for NXP Kinetis based SoCs. Signed-off-by: Kumar Gala <[email protected]>
Convert driver to utilize new pinctrl API. Update devicetree binding to require pinctrl-0 and pinctrl-names properties. Signed-off-by: Kumar Gala <[email protected]>
Remove board specific calls to pinmux_pin_set() for UART as the UART driver will now handle the pin configuration via the pinctrl API. Signed-off-by: Kumar Gala <[email protected]>
| .mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \ | ||
| (DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \ | ||
| (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \ | ||
| (DT_PROP(node_id, drive_open_drain) & PORT_PCR_ODE_MASK), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PORT_PCR_ODE_MASK is 0x20, If DT_PROP(node_id, drive_open_drain) return true(1) then '&' of them (1 & 0x20) will be 0. Instead we want 5th bit to be set here. Isn't it? Should we write here (DT_PROP(node_id, drive_open_drain) << PORT_PCR_ODE_SHIFT)? If this is true, then same can be applied to other '&' operations as well.
| .pin = DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 0), \ | ||
| .mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \ | ||
| (DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \ | ||
| (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't PORT_PCR_PE_MASK be used for pull-down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This should be (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PE_MASK) |.
| /** | ||
| * @file | ||
| * Public APIs for pin control drivers | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
| /** | ||
| * @brief Pin Controller Interface (NXP Kinetis) | ||
| * @defgroup pinctrl_interface_nxp_kinetis Pin Controller Interface | ||
| * @ingroup pinctrl_interface | ||
| * @{ | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this file doesn't expose any public API this can likely be removed
| compatible: "nxp,kinetis-uart" | ||
|
|
||
| include: uart-controller.yaml | ||
| include: [uart-controller.yaml, pinctrl-device.yaml] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: update binding description to mention pinctrl requirements, with some example.
| uintptr_t reg) | ||
| { | ||
| for (uint8_t i = 0U; i < pin_cnt; i++) { | ||
| pins[i].port_reg->PCR[pins[i].pin] = pins[i].mux; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some more valid bits in the PCR register, shouldn't this be read, clear lowest 16 bits, and '|' mux value operation? Maybe in some scenario, this can create problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which bits would you preserve here? The idea is that all these bits are controlled by the pinctrl driver based on the devicetree properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IRQC bits, which are currently configured by gpio_mcux.c driver for interrupt configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Right.
| int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, | ||
| uintptr_t reg) | ||
| { | ||
| for (uint8_t i = 0U; i < pin_cnt; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for (uint8_t i = 0U; i < pin_cnt; i++) { | |
| uint8_t i; | |
| for (i = 0U; i < pin_cnt; i++) { |
| .pin = DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 0), \ | ||
| .mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \ | ||
| (DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \ | ||
| (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This should be (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PE_MASK) |.
|
@galak Looks like a good starting point. We will likely need to add a custom drive strength dts property for selecting between high and low drive strength (the common I have opened a PR for setting the drive strength through the GPIO API here, but the drive strength applies to all digital outputs (e.g. high drive strength for PWM modulation of an LED): #39766 |
|
@galak What are your plans for getting this ready? If you do not have the time, I'd like to pick it up and get it ready for merging. |
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
|
@henrikbrixandersen, we are going to take this over as part of the larger transition of NXP parts to pinctrl. We have two alternative approaches for the RT platforms in #42238 and #41810 and plan on applying the adopted solution across the rest of the NXP platforms. |
No description provided.